<?=$system_message;?>
<div class="panel">Students Profiles</div>
<?if(isset($student)):?>
<div class="section-container auto" data-section>
	<section>
	 <p class="title" data-section-title><a href="#panel1">Personal Information</a></p>
	 <div class="content" data-section-content>
	   <?$this->load->view('student/_personal_information');?>
	 </div>
	</section>

	<section>
	 <p class="title" data-section-title><a href="#panel2">Family History</a></p>
	 <div class="content" data-section-content>
	   <?$this->load->view('student/_family_history')?>
	 </div>
	</section>


	<section>
	 <p class="title" data-section-title><a href="#panel3">Developmental History</a></p>
	 <div class="content" data-section-content>
	   <?$this->load->view('student/_developmental_history')?>
	 </div>
	</section>

	 <section>
	 <p class="title" data-section-title><a href="#panel4">Childhood Experiences</a></p>
	 <div class="content" data-section-content>
	   <?$this->load->view('student/_childhood_experiences');?>
	 </div>
	</section>

	 <section>
	 <p class="title" data-section-title><a href="#panel5">Health History</a></p>
	 <div class="content" data-section-content>
	   <?$this->load->view('student/_health_history');?>
	 </div>
	</section>

	<section>
	 <p class="title" data-section-title><a href="#panel6">Discipline</a></p>
	 <div class="content" data-section-content>
	   <?$this->load->view('student/_discipline')?>
	 </div>
	</section>
</div>

<script type="text/javascript">
	$(document).ready(function(){
		//create a new div
		var newDiv = document.createElement("div");
		var newDivChild = document.createElement("p"); 
		newDiv.id = "DOMdialog";
		newDivChild.className = "content";
		newDiv.appendChild(newDivChild)
		document.body.insertBefore(newDiv, document.body.childNodes[0]);

		//initiate jquery UI dialog
		var dialogDiv = $('div#DOMdialog');

		$(dialogDiv).dialog({
			autoOpen: false,
			show: "blind",
			hide: "explode",
			resizable : false,
			draggable: false,
			minHeight: 400,
			minWidth: 200,
			modal:true,
			open: function( event, ui ) {
				$(document).find('body').css('overflow','hidden');
			},
			close:function(){
				$(document).find('body').css('overflow','scroll');	
			},
			title:'Confirm Action.'
		});

		$('form#update_student_data').submit(function(e){
			e.preventDefault()
		});


		$('input[type=submit]').click(function(){

			var parentForm = $(this).parents('form');
			var form_data = parentForm.serialize();


			dialogDiv.find('p.content').text( 'Are You Sure you want to change selected data?' );
			dialogDiv.dialog('option', 'buttons', {
	            "Confirm" : function() {
	            	$(parentForm).block({ 
	            		css: { 
				            border: 'none', 
				            padding: '15px', 
				            backgroundColor: '#000', 
				            '-webkit-border-radius': '10px', 
				            '-moz-border-radius': '10px', 
				            opacity: .5, 
				            color: '#fff' 
				        },
	            		message: 'Processing Please Wait...' }); 

		   			$.ajax({
						url : parentForm.attr('action'),
						type:'POST',
						data: form_data
					}).done(function(result){
						if(result.status == true)
						{
							$.blockUI({ 
								css: { 
						            border: 'none', 
						            padding: '15px', 
						            backgroundColor: '#000', 
						            '-webkit-border-radius': '10px', 
						            '-moz-border-radius': '10px', 
						            opacity: .5, 
						            color: '#fff' 
					        	},
				        		message: 'Data was successfully updated, please click anywhere to continue.',onOverlayClick: $.unblockUI});
						}else{
							$.blockUI({ 
								css: { 
						            border: 'none', 
						            padding: '15px', 
						            backgroundColor: '#000', 
						            '-webkit-border-radius': '10px', 
						            '-moz-border-radius': '10px', 
						            opacity: .5, 
						            color: '#fff' 
						        },
				       		 	message: 'unable to refund student. Click anywhere to continue.',onOverlayClick: $.unblockUI});
						}
					}).fail(function(result){
						$.blockUI({
							css:{ 
					            border: 'none', 
					            padding: '15px', 
					            backgroundColor: '#000', 
					            '-webkit-border-radius': '10px', 
					            '-moz-border-radius': '10px', 
					            opacity: .5, 
						            color: '#fff' 
				        	},	
							message: 'unable to refund student. Click anywhere to continue',onOverlayClick: $.unblockUI});
					}).always(function(){
						$(parentForm).unblock();
						setTimeout($.unblockUI, 2000);
					});

					$(this).dialog("close");
	            },
	            "Cancel" : function() { $(this).dialog("close"); }
       	 	});

			
			dialogDiv.dialog("open");
			$('.ui-dialog-buttonpane').find('button').addClass('btn');

		});
	});
</script>
<?else:?>
	<div class="alert-box">
		Please Choose a student from the list above. If No Student is found, please contact school registrar.
	</div>
<?endif;?>